'use strict';

var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
const imageminJpegRecompress = require('imagemin-jpeg-recompress');
const imageminPngquant = require('imagemin-pngquant');

var config = {
  imgFilePath: "./dev/assets/img/**/*",
  imgDestPath: "./release/assets/img/",
}

gulp.task('imgmin', function () {
  var pngq = imageminPngquant({
    quality: 60, //0-100越大质量越高
    speed: 1, //1-10越大速度越快，质量越差
  }),
  jpgmin = imageminJpegRecompress({
            accurate: false, //高精度模式
            quality: "high", //图像质量:low, medium, high, veryhigh;
            method: "smallfry", //网格优化:mpe, ssim, ms-ssim , smallfry;
            min: 30, //最低质量
            loops: 6, //循环尝试次数, 默认为6;
            progressive: false, //基线优化
            subsample: "default" //子采样:default, disable;
        });
  gulp.src('./src/**/*')
    .pipe(imagemin([pngq,jpgmin]))
    .pipe(gulp.dest('./dist'))
});

gulp.task('default',['imgmin'])

